<?php include_once('Connections/tfccom_db.php'); ?>
<?php include_once('Connections/tfccom_select.php'); ?>
<?php

mysql_select_db($database_tfccom_db, $tfccom_db);


$priceMinMax = mysql_query($query_priceMinMax, $tfccom_db) or die(mysql_error());
$row_priceMinMax = mysql_fetch_assoc($priceMinMax);

$neighborhood = mysql_query($query_neighborhood, $tfccom_db) or die(mysql_error());
$row_neighborhood = mysql_fetch_assoc($neighborhood);

$bedroomsMinMax = mysql_query($query_bedroomsMinMax, $tfccom_db) or die(mysql_error());
$row_bedroomsMinMax = mysql_fetch_assoc($bedroomsMinMax);

$bathroomsMinMax = mysql_query($query_bathroomsMinMax, $tfccom_db) or die(mysql_error());
$row_bathroomsMinMax = mysql_fetch_assoc($bathroomsMinMax);

$building = mysql_query($query_building, $tfccom_db) or die(mysql_error());
$row_building = mysql_fetch_assoc($building);

$amenities = mysql_query($query_amenities, $tfccom_db) or die(mysql_error());
$row_amenities = mysql_fetch_assoc($amenities);

$square = mysql_query($query_square, $tfccom_db) or die(mysql_error());
$row_square = mysql_fetch_assoc($square);

$feature = mysql_query($query_feature, $tfccom_db) or die(mysql_error());
$row_feature = mysql_fetch_assoc($feature);
?>
<!DOCTYPE html>

<!--[if lt IE 7]>       <html class="ie6">  <![endif]-->
<!--[if IE 7]>          <html class="ie7">  <![endif]-->
<!--[if IE 8]>          <html class="ie8">  <![endif]-->
<!--[if gt IE 8]><!-->  <html lang='en-US'> <!--<![endif]-->

<head>
<meta charset='UTF-8' />
<me<meta name="viewport" content="width=640" />
<meta name="format-detection" content="telephone=no" />
<link rel="apple-touch-icon" href="iphone_icon.png" />
<link rel='shortcut icon' href='favicon.ico'>
<link rel='stylesheet' href='css/style.css'>
<link rel='stylesheet' href='css/uniform.default.css' />
<title></title>

<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery.livequery.min.js"></script>
<script src='js/jquery.uniform.min.js'></script>
<script type="text/javascript">

$.ajaxSetup({async: false});
$(function(){
	$("select").uniform();
    $('.options-button').livequery('click', function(event) {
	  $('#jquery_hide_options').load('search_options.php form');
	  $('#slide img').slideUp('fast');
	  $('.slogan').css({'position':'static'});
	  $("select").uniform();
	  //$('#slide').next().addClass("position:absolute");
	  });
	$('.options-button_2').livequery('click', function(event) {
	  $("#jquery_hide_options").load('home.php form');
	  $('#slide img').slideDown('fast');
	  $('.slogan').css({'position':'absolute'});
	  $("select").uniform();
	  //$("form").hide();
	  });  
});

</script>
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9374994-1']);
_gaq.push(['_setDomainName', 'tfcornerstone.com']);
_gaq.push(['_trackPageview']);

(function() {
 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 })();

</script>
</head>

<body class='search-options'>

<!-- ****** HEADER ****** -->
<div id='header'>
<a href="home.php"><div class='logo'><p>TF Cornerstone</p></div></a>
<div class='phone-button'><a href='tel:212.672.1000'>Call</a></div>
</div><!-- #header -->


<!-- ****** SLOGAN ****** -->
<div id='slogan'>
<p class='slogan'>Search for your new home</p>
</div><!-- #slide -->

<!-- ****** CONTENT ****** -->
<div id='content'>
<div id='jquery_hide_options'>
<form id="form1" name="form1" method="GET" action="search_results.php">
<label for='price-range'>Price Range</label>
  <select name="p" id="prices" style="font-size:2em">
    <option value="a">All prices</option>
    <option value="0-2000" <?php if (isset($_POST['p'])&&($_POST['p']=='0-2000')) echo 'selected'; ?>>Less Than $2,000</option>
    <option value="2000-3000" <?php if (isset($_POST['p'])&&($_POST['p']=='2000-3000')) echo 'selected'; ?>>$2,000 - $3,000</option>
    <option value="3000-4000" <?php if (isset($_POST['p'])&&($_POST['p']=='3000-4000')) echo 'selected'; ?>>$3,000 - $4,000</option>
    <option value="4000-5000" <?php if (isset($_POST['p'])&&($_POST['p']=='4000-5000')) echo 'selected'; ?>>$4,000 - $5,000</option>
    <option value="5000-6000" <?php if (isset($_POST['p'])&&($_POST['p']=='5000-6000')) echo 'selected'; ?>>OVER $5,000</option>
  </select>
<label for='neighbourhood'>Neighborhood</label>
  <select name="n" id="Neighborhood" style="font-size:2em">
    <option value="a">All neighborhoods</option>
  <?php
do {  
?>
    <option value="<?php echo $row_neighborhood['id']?>" <?php if (isset($_POST['n'])&&($_POST['n']==$row_neighborhood['id'])) echo 'selected'; ?>><?php echo $row_neighborhood['neighborhood']?></option>
    <?php
} while ($row_neighborhood = mysql_fetch_assoc($neighborhood));
  $rows = mysql_num_rows($neighborhood);
  if($rows > 0) {
      mysql_data_seek($neighborhood, 0);
	  $row_neighborhood = mysql_fetch_assoc($neighborhood);
  }
?>
  </select>
<label for='bedrooms'>Bedrooms</label>
  <select name="be" id="Bedrooms" style="font-size:2em">
    <option value="a" <?php if (isset($_POST['be'])&&($_POST['be']=='a')) echo 'selected'; ?>>All</option>
    <option value="0" <?php if (isset($_POST['be'])&&($_POST['be']=='0')) echo 'selected'; ?>>Studio</option>
    <?php
	for ($i=1;$i<=$row_bedroomsMinMax['maxbedrooms'];$i++)
	{
		if($i>=3){
			$shw=$i.'+ Bedrooms';
		}else if($i>=2){
			$shw=$i.' Bedrooms';
		}else{
			$shw=$i.' Bedroom';
		}
		?>
    <option value="<?php echo $i ?>" <?php if (isset($_POST['be'])&&($_POST['be']==$i)) echo 'selected'; ?>><?php echo $shw ?></option>
    <?php
		if($i>=3) break;
	}
	?>
  </select>
<label for='bathrooms'>Bathrooms</label>
  <select name="ba" id="Bathrooms" style="font-size:2em">
	<option value="a" <?php if (isset($_POST['ba'])&&($_POST['ba']=='a')) echo 'selected'; ?>>All</option>
    <?php
	for ($i=1;$i<=$row_bathroomsMinMax['maxbathrooms'];$i++)
	{
	?>
    <option value="<?php echo $i ?>" <?php if (isset($_POST['ba'])&&($_POST['ba']==$i)) echo 'selected'; ?>><?php echo $i ?></option>
    <?php
	}
	?>
  </select>
<label for='buildings'>Building</label>
  <select name="bu" id="Building" style="font-size:2em">
    <option value="a" <?php if (isset($_POST['bu'])&&($_POST['bu']=='a')) echo 'selected'; ?>>All addresses</option>
      <?php $i=0;
do {  $i++;
?>
    <option value="<?php echo $i?>" <?php if (isset($_POST['bu'])&&($_POST['bu']==$row_building['address'])) echo 'selected'; ?>><?php echo $row_building['address']?></option>
    <?php
} while ($row_building = mysql_fetch_assoc($building));
?>
  </select>
<label for='amenities'>Amenities</label>
<select name="am" id="Amenities" style="font-size:2em">
	<option value="a" <?php if (isset($_POST['am'])&&($_POST['am']=='a')) echo 'selected'; ?>>All</option>
    <?php
do {  
?>
    <option value="<?php echo $row_amenities['id']?>" <?php if (isset($_POST['am'])&&($_POST['am']==$row_amenities['id'])) echo 'selected'; ?>><?php echo $row_amenities['amenity']?></option>
    <?php
} while ($row_amenities = mysql_fetch_assoc($amenities));
?>
  </select>
<label for='apartment-size'>Apartment Size</label>
<?php $increment_2 = ($row_square['maxsquare'] - $row_square['minsquare'])/5;?>
			        <?php $square =  $row_square['minsquare'];?>
  <select name="a_s" id="Apartment_Size" style="font-size:2em">
    <option value="a" <?php if (isset($_POST['a_s'])&&($_POST['a_s']=='a')) echo 'selected'; ?>>All</option>
    <?php while($square < ($row_square['maxsquare'] - $increment_2)){?>
			          <?php $square = round(($square + $increment_2), -2);?>
			          <option value="<?php echo $square;?>" <?php if (isset($_POST['a_s'])&&($_POST['a_s']==$square)) echo 'selected'; ?>>up to <?php echo $square;?> sq.ft</option>
			          <?php }?>
    <option value="<?php echo $row_square['maxsquare']; ?>" <?php if (isset($_POST['a_s'])&&($_POST['a_s']==$row_square['maxsquare'])) echo 'selected'; ?>>up to <?php echo $row_square['maxsquare']; ?> sq.ft</option>
  </select>
  <input type="hidden" name="a_t" id="Apartment_Type" value="a"/>
<!--<label for='Apartment Type'>Condominiums</label>
  <select name="a_t" id="Apartment_Type" style="font-size:2em">
    <option value="a" <?php if (isset($_POST['a_t'])&&($_POST['a_t']=='a')) echo 'selected'; ?>>All</option>
    <option value="r" <?php if (isset($_POST['a_t'])&&($_POST['a_t']=='r')) echo 'selected'; ?>>Rentals</option>
    <option value="s" <?php if (isset($_POST['a_t'])&&($_POST['a_t']=='s')) echo 'selected'; ?>>Sales</option>
  </select>
-->    <input type="button" name="Hide Options" value="Hide Options" class='options-button_2' />
        <input name="Go" type="submit" id="Go" value="Search" class='submit' />
        </form>
         
        </div>
      <h2>Featured listings</h2>
<?php	
	do
	{
?>
    <div class='listing'><a href='unit_page.php?id=<?php echo $row_feature['id']; ?>'><div style=" background:url(http://www.tfcornerstone.com/images/building/<?php echo $row_feature['image'];?>) no-repeat 50% 0; background-position:50% 50%;width:292px; height:210px;overflow:hidden; float:left"></div>
<div class='listing-info'>
	<p class='first-line'><?php echo($row_feature['name']) ?></p><p><?php echo($row_feature['neighborhood']) ?></p><p><?php
		if($row_feature['num_bedrooms']==0)
		{
		  	echo 'Studio';
		}
		else
		{
		   echo($row_feature['num_bedrooms']) ?> BD<?php    }?> / <?php echo($row_feature['num_bathrooms']) ?> BA</p><p>$<?php echo(number_format($row_feature['price'])) ?>&nbsp;<?php echo($row_feature['apt_type']) ?></p> </div></a>
</div><!-- .listing -->
          
 <?php } while ($row_feature = mysql_fetch_assoc($feature));
 
 ?>
 </div><!-- #content -->

 <!-- ****** FOOTER ****** -->
<div id='footer'>

<a href="home.php"><div class='logo'><p>TF Cornerstone</p></div></a>


<div class='contacts'>
<p>387 Park Ave South, New York, NY 10016</p>
<p>MAIN: 212.672.1000 FAX: 212.672.1001</p>
</div>

<a class='full-site-button' href='http://www.tfcornerstone.com?desktop'>FULL SITE</a>

<div style="color:white; margin:20px 0 20px 0;overflow:auto">
          <div style="float:left;border-right:solid white;padding:0 30px 0 30px"><a href="home.php" style="font-size:28px;color:white">HOME</a></div>
          <div style="float:left;border-right:solid white;padding:0 30px 0 30px"><a href="about.php" style="font-size:28px;color:white">ABOUT</a></div>
          <div style="float:left;padding:0 0 0 30px"><a href="#" style="font-size:28px;color:white">DISCLAIMER</a></div>
</div>
<ul class='icons'>
<li class='google-plus'><a href="http://gplus.to/tfcornerstone" target="_blank">Google+</a></li>
<li class='twitter'><a href="http://twitter.com/#!/tfcornerstone" target="_blank">Twitter</a></li>
<li class='facebook'><a href="https://www.facebook.com/TFCrealestate" target="_blank">Facebook</a></li>
<li class='youtube'><a href="http://www.youtube.com/tfcornerstone" target="_blank">Youtube</a></li>
<li class='linked-in'><a href="http://www.linkedin.com/company/tf-cornerstone" target="_blank">Linked In</a></li>
<li class='rss'>
<?php
if(strstr($_SERVER['HTTP_USER_AGENT'],'Android')) { 
?>
	<a href="http://www.tfcornerstone.com/new-york-city-life/" target="_blank">RSS</a>
<?php	
} 
else { 
?>
	<a href="http://www.tfcornerstone.com/new-york-city-life/feed/" target="_blank">RSS</a>
<?php
}
 ?></li>
<li class='helper'></li>
</ul>

<p class='copyright'>&copy; 2012 <span>TF Cornerstone</span> INC</p>
<p class='copyright' style=" font-size:12px">EQUAL HOUSING OPPORTUNITY</p>
</div><!-- #footer -->

</body>
</html>
